package com.linked.gateway.resolver;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author :dbq
 * @date : 2022/9/23 16:00
 */
@Component
public class HostAddrKeyResolver implements KeyResolver{

    private final static Logger LOGGER = LoggerFactory.getLogger(HostAddrKeyResolver.class);

    @Override
    public Mono<String> resolve(ServerWebExchange exchange) {
        LOGGER.info("限流!");
        return Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
    }
}
